package com.hp.attendance.serlvet.empmanage.lizhi;

import com.hp.attendance.entity.History;
import com.hp.attendance.service.HistoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/historyLXDetail")
public class EmpManageLXHistoryDetailServlet extends HttpServlet {
    private HistoryService historyService = new HistoryService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            int id = Integer.parseInt(req.getParameter("id"));
            String name1 = req.getParameter("name1");
            String name2 = req.getParameter("name2");
            History history = historyService.getHistory(id);
            req.setAttribute("name1",name1);
            req.setAttribute("name2",name2);
            req.setAttribute("history",history);
            req.getRequestDispatcher("pages/history_detail_2.jsp").forward(req,resp);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
